#pragma once

extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/imgutils.h>
#include <libavutil/timestamp.h>
// #include <libswscale/swscale.h>

#include "hb_comm_venc.h"
#include "hb_comm_vdec.h"
#include "hb_venc.h"
#include "hb_vdec.h"
#include "hb_vio_interface.h"
#include "hb_sys.h"
#include "ion.h"
}

#include "camera/hikbase.h"
#include "stream/total_struct.h"
#include "stream/horizon/stream_puller_base.h"

namespace stream {


class HBStreamPullerNET: public HBStreamPullerBase
{
public:
  HBStreamPullerNET(StreamPullerInfo* sifo, LogInfo* log_info);
  ~HBStreamPullerNET();

public:
  int init_params();
  int start_pull();

  int get_frame(stream::ImageBlob& buffer);

private:
  int start_pull_imp();
  int start_pull_listener();
  int start_pull_listener_imp();

  void release_ffmpeg();
  int build_dec_seq_header(uint8_t* pbHeader, const AVStream* st, int* sizelength);

public:


private:


  AVFormatContext *ifmt_ctx = nullptr;
  AVDictionary *optionsDict = nullptr;
  AVStream *pVst = nullptr;
  AVCodecContext *pVideoCodecCtx = nullptr;
  AVCodec *pVideoCodec = nullptr;
  AVFrame *pFrame = nullptr;
  int video_st_index = -1;
  int audio_st_index = -1;

  // init module
  // void *display = nullptr;
  // void *vps = nullptr;

  std::string rtsp_main;

};


}   // namespace camera
